<html>
<head><meta charset="utf-8"><title>issue-51195-warning-about-variable-declaration-order · t-compiler/wg-nll · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/index.html">t-compiler/wg-nll</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html">issue-51195-warning-about-variable-declaration-order</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="127800967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127800967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127800967">(Jun 09 2018 at 00:43)</a>:</h4>
<p>OK, <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span>, so talking about <a href="https://github.com/rust-lang/rust/issues/51195" target="_blank" title="https://github.com/rust-lang/rust/issues/51195">https://github.com/rust-lang/rust/issues/51195</a>...</p>



<a name="127800973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127800973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127800973">(Jun 09 2018 at 00:43)</a>:</h4>
<p>I'm a little bit confused because that example <a href="https://play.rust-lang.org/?gist=e7b74556cdee598c19c2ac03cd10db1e&amp;version=nightly&amp;mode=debug" target="_blank" title="https://play.rust-lang.org/?gist=e7b74556cdee598c19c2ac03cd10db1e&amp;version=nightly&amp;mode=debug">doesn't seem to give an error with NLL</a>; you could modify to make it do so, though</p>



<a name="127800975"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127800975" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127800975">(Jun 09 2018 at 00:43)</a>:</h4>
<p>I'm not sure if <span class="user-mention" data-user-id="116083">@pnkfelix</span> had a modified version in mind</p>



<a name="127804800"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127804800" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127804800">(Jun 09 2018 at 03:08)</a>:</h4>
<p>I see the error shows up when you do <code>rustc -Zborrowck=mir -Ztwo-phase-borrows src/test/ui/error-codes/E0597.rs</code></p>



<a name="127804801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127804801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127804801">(Jun 09 2018 at 03:08)</a>:</h4>
<div class="codehilite"><pre><span></span>[santiago@archlinux rust1 (diagnostic-suggest-drop-in-reverse)]$ rustc +stage1 -Zborrowck=mir -Ztwo-phase-borrows src/test/ui/error-codes/E0597.rs
error[E0597]: `y` does not live long enough
  --&gt; src/test/ui/error-codes/E0597.rs:18:16
   |
18 |     x.x = Some(&amp;y);
   |                ^^ borrowed value does not live long enough
19 |     //~^ `y` does not live long enough [E0597]
20 | }
   | -
   | |
   | borrowed value only lives until here
   | borrow later used here, when `x` is dropped
   |
   = note: values in a scope are dropped in the opposite order they are defined

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
</pre></div>



<a name="127804852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127804852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127804852">(Jun 09 2018 at 03:10)</a>:</h4>
<p>and runtest is doing exactly that, so we have <a href="https://github.com/rust-lang/rust/blob/master/src/test/ui/error-codes/E0597.nll.stderr" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/test/ui/error-codes/E0597.nll.stderr">https://github.com/rust-lang/rust/blob/master/src/test/ui/error-codes/E0597.nll.stderr</a></p>



<a name="127804946"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127804946" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127804946">(Jun 09 2018 at 03:14)</a>:</h4>
<p>because of <a href="https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/runtest.rs#L1745" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/runtest.rs#L1745">https://github.com/rust-lang/rust/blob/master/src/tools/compiletest/src/runtest.rs#L1745</a></p>



<a name="127804948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127804948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127804948">(Jun 09 2018 at 03:14)</a>:</h4>
<p>we need a -Znll flag to do the right thing</p>



<a name="127805158"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127805158" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127805158">(Jun 09 2018 at 03:22)</a>:</h4>
<p>and I guess all that happens because of <a href="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L310" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L310">https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L310</a></p>



<a name="127812312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812312">(Jun 09 2018 at 08:03)</a>:</h4>
<p>huh, I don't see any such error</p>



<a name="127812315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812315">(Jun 09 2018 at 08:03)</a>:</h4>
<p>ah I see, it's a modified version of the test</p>



<a name="127812357"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812357" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812357">(Jun 09 2018 at 08:04)</a>:</h4>
<p>so it already says "borrow later used here, when <code>x</code> is dropped"</p>



<a name="127812358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812358">(Jun 09 2018 at 08:04)</a>:</h4>
<p>which feels arguably <em>better</em> than the original</p>



<a name="127812359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812359">(Jun 09 2018 at 08:04)</a>:</h4>
<p>but it would probably be better still with the <code>note</code></p>



<a name="127812409"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812409" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812409">(Jun 09 2018 at 08:06)</a>:</h4>
<p>so let me think — we want the note to trigger I think when two things happen:</p>
<p>(1) a local variable is borrowed<br>
(2) the last use is when <em>another</em> local variable is dropped</p>



<a name="127812416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127812416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127812416">(Jun 09 2018 at 08:07)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span>, you added that note that tells us when the last use is a drop :)</p>



<a name="127813741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127813741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127813741">(Jun 09 2018 at 08:57)</a>:</h4>
<p>You all have probably figured this out, but yes, that test needed to be updated at the time this issue was filed. And subsequently was updated,</p>



<a name="127833470"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833470" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833470">(Jun 09 2018 at 21:20)</a>:</h4>
<p>I don't understand how is the deal with <a href="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312">https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312</a></p>



<a name="127833473"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833473" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833473">(Jun 09 2018 at 21:20)</a>:</h4>
<p>why this test is ok with feature(nll) and not with -Zborrowck=mir -Ztwo-phase-borrow ?</p>



<a name="127833479"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833479" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833479">(Jun 09 2018 at 21:21)</a>:</h4>
<p>or are we talking about different tests</p>



<a name="127833480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833480">(Jun 09 2018 at 21:21)</a>:</h4>
<p>/me confused</p>



<a name="127833521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833521">(Jun 09 2018 at 21:22)</a>:</h4>
<blockquote>
<p>why this test is ok with feature(nll) and not with -Zborrowck=mir -Ztwo-phase-borrow ?</p>
</blockquote>
<p>it's not, I was confused — the test has been modified since the version that I was looking at</p>



<a name="127833528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833528">(Jun 09 2018 at 21:23)</a>:</h4>
<blockquote>
<p>I don't understand how is the deal with <a href="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312">https://github.com/rust-lang/rust/blob/master/src/librustc/infer/error_reporting/mod.rs#L307-L312</a></p>
</blockquote>
<p>we skip errors there because the MIR borrow check tests the same stuff (but more precisely)</p>



<a name="127833575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833575">(Jun 09 2018 at 21:24)</a>:</h4>
<p>ahh, now it makes sense :)</p>



<a name="127833576"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833576" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833576">(Jun 09 2018 at 21:24)</a>:</h4>
<p>anyway, no time during this weekend</p>



<a name="127833581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833581">(Jun 09 2018 at 21:24)</a>:</h4>
<p>will get back to this on monday</p>



<a name="127833584"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833584" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833584">(Jun 09 2018 at 21:24)</a>:</h4>
<p>anyway, I'm not sure about what you've said first</p>



<a name="127833592"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833592" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833592">(Jun 09 2018 at 21:25)</a>:</h4>
<blockquote>
<p>so let me think — we want the note to trigger I think when two things happen:</p>
<p>(1) a local variable is borrowed<br>
(2) the last use is when <em>another</em> local variable is dropped</p>
</blockquote>
<p>ahh ok ok, re-reading this thing makes sense</p>



<a name="127833594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833594">(Jun 09 2018 at 21:25)</a>:</h4>
<blockquote>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span>, you added that note that tells us when the last use is a drop :)</p>
</blockquote>
<p>what do you mean by this?</p>



<a name="127833635"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833635" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833635">(Jun 09 2018 at 21:26)</a>:</h4>
<p>I mean that you added the code that causes that message to print out :)</p>



<a name="127833639"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833639" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833639">(Jun 09 2018 at 21:26)</a>:</h4>
<p>I think...</p>



<a name="127833641"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833641" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833641">(Jun 09 2018 at 21:26)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/pull/49808/" target="_blank" title="https://github.com/rust-lang/rust/pull/49808/">https://github.com/rust-lang/rust/pull/49808/</a></p>



<a name="127833642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127833642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127833642">(Jun 09 2018 at 21:27)</a>:</h4>
<p>anyway, doesn't matter :)</p>



<a name="127837940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127837940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127837940">(Jun 10 2018 at 00:18)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> just to clarify what I had in mind, I <a href="https://github.com/rust-lang/rust/issues/51195#issuecomment-396008556" target="_blank" title="https://github.com/rust-lang/rust/issues/51195#issuecomment-396008556">left some notes in the issue</a>.</p>



<a name="127858381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127858381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127858381">(Jun 10 2018 at 13:59)</a>:</h4>
<p><span class="emoji emoji-1f44d" title="+1">:+1:</span></p>



<a name="127948650"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127948650" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127948650">(Jun 12 2018 at 11:22)</a>:</h4>
<p>so <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> I did indeed change my mind between the first comment and the later ones.</p>



<a name="127948829"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127948829" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127948829">(Jun 12 2018 at 11:28)</a>:</h4>
<p>Recall that the basic structure of the "error reporting" phase of the borrow check is like this:</p>
<ul>
<li>Walk over the MIR</li>
<li>For each "action" of various kinds, check if there is a conflicting loan:<ul>
<li>In this particular case, if there is a <code>StorageDead(y)</code> or <code>Drop(y)</code>, that means that the stack space for a local variable is being freed</li>
<li>Therefore, if there is a loan of that variable <code>y</code>, that's a problem and we should report an error</li>
</ul>
</li>
</ul>
<p>Currently, if there is a loan of that variable <code>y</code>, we report an error, and then we invoke <a href="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L26-L31" target="_blank" title="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L26-L31"><code>explain_why_borrow_contains_point</code></a>. This tries to report <em>why</em> the variable <code>y</code> is still considered borrowed. In the case of our example, we find that the reason is because <a href="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L56-L89" target="_blank" title="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L56-L89">that reference is going to be used in the <code>Drop(x)</code> for some other variable <code>x</code></a>.</p>
<p>What I am saying is that <em>in precisely these conditions</em>, where the current statement is a <code>Drop</code>/<code>StorageDead</code> <em>and</em> the final use is <em>another</em> <code>Drop</code>, we should report the note about the relative ordering of variables. This is because that means that</p>
<ul>
<li>we are dropping one variable (<code>y</code>)</li>
<li>but a reference to that variable  is going to be used in the destructor of another variable (<code>x</code>)</li>
</ul>
<p>It seems like precisely here is where the relative order of variables is relevant.</p>



<a name="127953950"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127953950" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127953950">(Jun 12 2018 at 13:38)</a>:</h4>
<p>hey <span class="user-mention" data-user-id="116009">@nikomatsakis</span> ok, some questions</p>



<a name="127953959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127953959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127953959">(Jun 12 2018 at 13:38)</a>:</h4>
<blockquote>
<p>In this particular case, if there is a StorageDead(y) or Drop(y), that means that the stack space for a local variable is being freed</p>
</blockquote>
<p>how do I know that this is for <code>y</code> and not for <code>x</code>?</p>



<a name="127953969"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127953969" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127953969">(Jun 12 2018 at 13:39)</a>:</h4>
<p>well, first off, if they were the <em>same</em> variable, there'd be no error</p>



<a name="127953974"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127953974" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127953974">(Jun 12 2018 at 13:39)</a>:</h4>
<p>(actually, hmm, is that known to be true? maybe there can be, if you setup a cycle...)</p>



<a name="127953978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127953978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127953978">(Jun 12 2018 at 13:40)</a>:</h4>
<p>the variables names are, in any case, available to us</p>



<a name="127954023"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954023" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954023">(Jun 12 2018 at 13:40)</a>:</h4>
<p>though you may have to add  some logic to thread them through</p>



<a name="127954176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954176">(Jun 12 2018 at 13:45)</a>:</h4>
<p>so you're saying that I have access to both things?</p>



<a name="127954179"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954179" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954179">(Jun 12 2018 at 13:45)</a>:</h4>
<p>one if <code>local</code> and the other one, which one is it?</p>



<a name="127954227"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954227" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954227">(Jun 12 2018 at 13:46)</a>:</h4>
<p>can find it using borrow info, I guess</p>



<a name="127954323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954323">(Jun 12 2018 at 13:49)</a>:</h4>
<p>sorry, got distracted =)</p>



<a name="127954324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954324">(Jun 12 2018 at 13:49)</a>:</h4>
<p>yes, the borrow info</p>



<a name="127954325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954325">(Jun 12 2018 at 13:49)</a>:</h4>
<p>the other data we might have to add to the data that is passed in</p>



<a name="127954326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954326">(Jun 12 2018 at 13:49)</a>:</h4>
<p>it comes from the MIR</p>



<a name="127954381"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954381" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954381">(Jun 12 2018 at 13:50)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> so <a href="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/mod.rs#L501-L508" target="_blank" title="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/mod.rs#L501-L508">here</a> is where the call originates (or maybe the arm for <code>Drop</code>)</p>



<a name="127954386"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954386" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954386">(Jun 12 2018 at 13:50)</a>:</h4>
<p>that variable <code>local</code> contains the variable <code>y</code></p>



<a name="127954388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954388">(Jun 12 2018 at 13:50)</a>:</h4>
<p>so .. actually ..</p>



<a name="127954476"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954476" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954476">(Jun 12 2018 at 13:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> well it seems like <a href="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L26" target="_blank" title="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L26"><code>explain_why_borrow_contains_point</code></a> is not currently given the path that was being accessed</p>



<a name="127954478"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127954478" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127954478">(Jun 12 2018 at 13:53)</a>:</h4>
<p>but if it were, that would contain the variable <code>y</code> that is being dropped</p>



<a name="127956359"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127956359" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127956359">(Jun 12 2018 at 14:36)</a>:</h4>
<p>didn't understand that last thing</p>



<a name="127956393"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127956393" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127956393">(Jun 12 2018 at 14:36)</a>:</h4>
<p>you meant <code>x</code>?</p>



<a name="127956402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127956402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127956402">(Jun 12 2018 at 14:36)</a>:</h4>
<p>isn't what represents <code>y</code>, the one we have there under <code>local</code>?</p>



<a name="127956794"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127956794" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127956794">(Jun 12 2018 at 14:44)</a>:</h4>
<p>I guess I gave a different meaning to the word contain</p>



<a name="127956988"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127956988" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127956988">(Jun 12 2018 at 14:48)</a>:</h4>
<p>ok, I see local is <code>x</code></p>



<a name="127959701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959701">(Jun 12 2018 at 15:39)</a>:</h4>
<p>yes</p>



<a name="127959774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959774">(Jun 12 2018 at 15:40)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> so ... let me recap a bit to see if I'm correct</p>



<a name="127959804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959804">(Jun 12 2018 at 15:41)</a>:</h4>
<p>I'd need in this Some arm <a href="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L59" target="_blank" title="https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L59">https://github.com/rust-lang/rust/blob/2a0062974a5225847fc43d5522c4dc3718173fe5/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L59</a></p>



<a name="127959810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959810">(Jun 12 2018 at 15:41)</a>:</h4>
<p>unsure if the same happens when it's a temporary ...</p>



<a name="127959869"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959869" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959869">(Jun 12 2018 at 15:42)</a>:</h4>
<p>in that case would be in the Some of the previous line</p>



<a name="127959876"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959876" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959876">(Jun 12 2018 at 15:42)</a>:</h4>
<p>I have "x" in local</p>



<a name="127959893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959893">(Jun 12 2018 at 15:43)</a>:</h4>
<p>need to find in borrow if there's something dropped</p>



<a name="127959899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959899">(Jun 12 2018 at 15:43)</a>:</h4>
<p>looking for StorageDead or Drop</p>



<a name="127959918"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127959918" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127959918">(Jun 12 2018 at 15:44)</a>:</h4>
<p>and print the note for that case</p>



<a name="127962573"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962573" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962573">(Jun 12 2018 at 16:42)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> nevermind about all this</p>



<a name="127962579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962579">(Jun 12 2018 at 16:42)</a>:</h4>
<p>ok :) just logged in</p>



<a name="127962580"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962580" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962580">(Jun 12 2018 at 16:42)</a>:</h4>
<p>I'm pushing something to discuss</p>



<a name="127962589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962589">(Jun 12 2018 at 16:42)</a>:</h4>
<p>yeah, so you connected</p>



<a name="127962605"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962605" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962605">(Jun 12 2018 at 16:43)</a>:</h4>
<p>I got the point p of where the use happens</p>



<a name="127962608"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962608" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962608">(Jun 12 2018 at 16:43)</a>:</h4>
<p>and got the statements kind</p>



<a name="127962610"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962610" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962610">(Jun 12 2018 at 16:43)</a>:</h4>
<p>and I'm checking if that's a StorageDead</p>



<a name="127962617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962617">(Jun 12 2018 at 16:44)</a>:</h4>
<p>ok, sounds good, I think <code>Drop</code> also counts</p>



<a name="127962633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962633">(Jun 12 2018 at 16:44)</a>:</h4>
<p>there's no kind <code>Drop</code> or <code>Call</code> or anything like that</p>



<a name="127962660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962660">(Jun 12 2018 at 16:44)</a>:</h4>
<p>well</p>



<a name="127962668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962668">(Jun 12 2018 at 16:44)</a>:</h4>
<p>I was surprised that there's no kind <code>Call</code> or something</p>



<a name="127962670"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962670" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962670">(Jun 12 2018 at 16:44)</a>:</h4>
<p>unsure what I may be missing</p>



<a name="127962679"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962679" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962679">(Jun 12 2018 at 16:44)</a>:</h4>
<p>you are referring to <code>Call</code> because it's invoking a desturctor?</p>



<a name="127962680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962680">(Jun 12 2018 at 16:44)</a>:</h4>
<p>in MIR, that's a special statement</p>



<a name="127962681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962681">(Jun 12 2018 at 16:44)</a>:</h4>
<p>called <code>Drop</code></p>



<a name="127962696"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962696" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962696">(Jun 12 2018 at 16:45)</a>:</h4>
<p>first of all remind me what are <code>StorageDead</code> and <code>Drop</code></p>



<a name="127962699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962699">(Jun 12 2018 at 16:45)</a>:</h4>
<p>maybe what I think they are is wrong :)</p>



<a name="127962702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962702">(Jun 12 2018 at 16:45)</a>:</h4>
<p>that call occurs here <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/mod.rs#L864" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/mod.rs#L864">https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/mod.rs#L864</a></p>



<a name="127962707"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962707" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962707">(Jun 12 2018 at 16:45)</a>:</h4>
<p>Ah, <code>StorageDead</code> means "Free the stack space for this variable"</p>



<a name="127962710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962710">(Jun 12 2018 at 16:45)</a>:</h4>
<p>ya</p>



<a name="127962711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962711">(Jun 12 2018 at 16:45)</a>:</h4>
<p><code>Drop</code> means "destroy the value currently in this variable"</p>



<a name="127962752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962752">(Jun 12 2018 at 16:46)</a>:</h4>
<p>ok</p>



<a name="127962758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962758">(Jun 12 2018 at 16:46)</a>:</h4>
<p>yes, it was what I was thinking</p>



<a name="127962760"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962760" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962760">(Jun 12 2018 at 16:46)</a>:</h4>
<p>the key thing is, when we call <code>access_place</code>, we tell if what <strong>kind</strong> of access:</p>



<a name="127962764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962764">(Jun 12 2018 at 16:46)</a>:</h4>
<p><code>Write(WriteKind::StorageDeadOrDrop)</code> is what we want</p>



<a name="127962766"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962766" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962766">(Jun 12 2018 at 16:46)</a>:</h4>
<p>but <code>Drop</code> is when you call that explicitly? or not necessarily?</p>



<a name="127962771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962771">(Jun 12 2018 at 16:46)</a>:</h4>
<p>that is the value of <code>kind.1</code> where <code>kind</code> is <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/mod.rs#L883" target="_blank" title="https://github.com/rust-lang/rust/blob/master/src/librustc_mir/borrow_check/mod.rs#L883">this parameter here</a></p>



<a name="127962811"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962811" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962811">(Jun 12 2018 at 16:47)</a>:</h4>
<blockquote>
<p>but <code>Drop</code> is when you call that explicitly? or not necessarily?</p>
</blockquote>
<p>I don't know what you are referring to here :)</p>



<a name="127962851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962851">(Jun 12 2018 at 16:48)</a>:</h4>
<p>when a variable goes out of scope: 2 things potentially happen</p>



<a name="127962886"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962886" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962886">(Jun 12 2018 at 16:49)</a>:</h4>
<p>1. (optional) the current value is dropped<br>
2. (optional) the storage is reclaimed</p>
<p>the first step is optional because -- in some cases -- we can clearly see it is not needed; e.g., if the type is a <code>u32</code></p>
<p>the second step is optional because -- in some cases -- it's not worth dropping the stack space for individual variables; in particular, during unwinding. In that case, we have a special check at the end that drops all the variables in one big step.</p>



<a name="127962957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962957">(Jun 12 2018 at 16:50)</a>:</h4>
<p>I see</p>



<a name="127962965"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962965" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962965">(Jun 12 2018 at 16:50)</a>:</h4>
<p>/me takes some notes for a rustc-guide chapter on MIR</p>



<a name="127962967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127962967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127962967">(Jun 12 2018 at 16:50)</a>:</h4>
<p>when you say dropped that may also happen by drop(x)?</p>



<a name="127963028"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963028" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963028">(Jun 12 2018 at 16:52)</a>:</h4>
<p>no</p>



<a name="127963031"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963031" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963031">(Jun 12 2018 at 16:52)</a>:</h4>
<p>that is just a user function</p>



<a name="127963035"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963035" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963035">(Jun 12 2018 at 16:52)</a>:</h4>
<p>totally unrelated (from the MIR point of view)</p>



<a name="127963043"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963043" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963043">(Jun 12 2018 at 16:52)</a>:</h4>
<p>ya</p>



<a name="127963047"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963047" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963047">(Jun 12 2018 at 16:52)</a>:</h4>
<p>that is, if you write <code>drop(x)</code>, that is just a call</p>



<a name="127963048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963048">(Jun 12 2018 at 16:52)</a>:</h4>
<p>right, makes sense</p>



<a name="127963052"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963052" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963052">(Jun 12 2018 at 16:52)</a>:</h4>
<p>a <code>Drop</code> terminator is <em>only</em> used when a variable goes out of scope</p>



<a name="127963059"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963059" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963059">(Jun 12 2018 at 16:53)</a>:</h4>
<p>yeah, you are passing ownership and when it goes out of scope it will be dropped for real :)</p>



<a name="127963125"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963125" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963125">(Jun 12 2018 at 16:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> take a look at this <a href="https://github.com/spastorino/rust/commit/9004ec75ebc56649e357fd297c80e2add84dfa1e" target="_blank" title="https://github.com/spastorino/rust/commit/9004ec75ebc56649e357fd297c80e2add84dfa1e">https://github.com/spastorino/rust/commit/9004ec75ebc56649e357fd297c80e2add84dfa1e</a></p>



<a name="127963140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963140">(Jun 12 2018 at 16:55)</a>:</h4>
<p>what was my first attempt</p>



<a name="127963211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963211">(Jun 12 2018 at 16:57)</a>:</h4>
<p>I still need to find the connection between <code>access_place</code> and <code>explain_why_borrow_contains_point</code> because I haven't yet</p>



<a name="127963879"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963879" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963879">(Jun 12 2018 at 17:13)</a>:</h4>
<p>you'd have to trace it through</p>



<a name="127963927"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127963927" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127963927">(Jun 12 2018 at 17:14)</a>:</h4>
<p>I can help if you want but maybe you want to do it for yourself :)</p>



<a name="127978392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127978392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127978392">(Jun 12 2018 at 22:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> how goes?</p>



<a name="127983510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127983510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127983510">(Jun 13 2018 at 01:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> didn't do that much, just left this thing compiling in debug mode, and it took a while</p>



<a name="127988228"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127988228" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127988228">(Jun 13 2018 at 03:52)</a>:</h4>
<p>at least had some minutes to run it with the debugger ...</p>



<a name="127988230"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127988230" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127988230">(Jun 13 2018 at 03:52)</a>:</h4>
<div class="codehilite"><pre><span></span>#0  rustc_mir::borrow_check::nll::explain_borrow::&lt;impl rustc_mir::borrow_check::MirBorrowckCtxt&lt;&#39;cx, &#39;gcx, &#39;tcx&gt;&gt;::explain_why_borrow_contains_point (self=0x7ffffffd5470, context=Context = {...},
    borrow=0x555555c26200, err=0x7ffffffd0440) at librustc_mir/borrow_check/nll/explain_borrow/mod.rs:32
#1  0x00007ffff26dee75 in rustc_mir::borrow_check::error_reporting::&lt;impl rustc_mir::borrow_check::MirBorrowckCtxt&lt;&#39;cx, &#39;gcx, &#39;tcx&gt;&gt;::report_unscoped_local_value_does_not_live_long_enough (self=0x7ffffffd5470,
    context=Context = {...}, name=0x7ffffffd09a8, scope_tree=0x7ffffffd0758, borrow=0x555555c26200, drop_span=Span = {...}, borrow_span=Span = {...}, _proper_span=Span = {...})
    at librustc_mir/borrow_check/error_reporting.rs:547
#2  0x00007ffff26ddc17 in rustc_mir::borrow_check::error_reporting::&lt;impl rustc_mir::borrow_check::MirBorrowckCtxt&lt;&#39;cx, &#39;gcx, &#39;tcx&gt;&gt;::report_borrowed_value_does_not_live_long_enough (self=0x7ffffffd5470,
    context=Context = {...}, borrow=0x555555c26200, drop_span=Span = {...}) at librustc_mir/borrow_check/error_reporting.rs:445
#3  0x00007ffff2425388 in rustc_mir::borrow_check::MirBorrowckCtxt::check_access_for_conflict::{{closure}} (this=0x7ffffffd5470, borrow_index=BorrowIndex = {...}, borrow=0x555555c26200)
    at librustc_mir/borrow_check/mod.rs:1050
#4  0x00007ffff241ee81 in rustc_mir::borrow_check::path_utils::each_borrow_involving_path (s=0x7ffffffd5470, tcx=TyCtxt = {...}, mir=0x7ffffffd3538, access_place={...}, borrow_set=0x555555c1fb20,
    candidates=..., op=closure = {...}) at librustc_mir/borrow_check/path_utils.rs:71
#5  0x00007ffff26eb59e in rustc_mir::borrow_check::MirBorrowckCtxt::check_access_for_conflict (self=0x7ffffffd5470, context=Context = {...}, place_span={...}, Python Exception &lt;class &#39;gdb.error&#39;&gt; Cannot convert value to long.:
sd=..., rw=Write = {...},
    flow_state=0x7ffffffd5658) at librustc_mir/borrow_check/mod.rs:958
#6  0x00007ffff26eaae5 in rustc_mir::borrow_check::MirBorrowckCtxt::access_place (self=0x7ffffffd5470, context=Context = {...}, place_span={...}, kind={...},
    is_local_mutation_allowed=rustc_mir::borrow_check::LocalMutationIsAllowed::Yes, flow_state=0x7ffffffd5658) at librustc_mir/borrow_check/mod.rs:919
</pre></div>



<a name="127988292"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/127988292" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#127988292">(Jun 13 2018 at 03:54)</a>:</h4>
<p>now you wanted me to pass <code>ReadOrWrite</code> down from <code>access_place</code> to <code>explain_why_borrow_contains_point</code>?</p>



<a name="128004914"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128004914" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128004914">(Jun 13 2018 at 12:10)</a>:</h4>
<p>basically yes</p>



<a name="128011300"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011300" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011300">(Jun 13 2018 at 14:28)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> adding this</p>



<a name="128011316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011316">(Jun 13 2018 at 14:29)</a>:</h4>
<p>of course this ends spreading to a lot of places</p>



<a name="128011323"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011323" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011323">(Jun 13 2018 at 14:29)</a>:</h4>
<p>were you imagining doing Option&lt;ReadOrWrite&gt; I guess</p>



<a name="128011326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011326">(Jun 13 2018 at 14:29)</a>:</h4>
<p>so I can pass None in most of places</p>



<a name="128011588"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011588" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011588">(Jun 13 2018 at 14:34)</a>:</h4>
<p>I hadn't really thought about it tbh</p>



<a name="128011590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011590">(Jun 13 2018 at 14:34)</a>:</h4>
<p><code>Option</code> seems potentially ok</p>



<a name="128011594"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011594" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011594">(Jun 13 2018 at 14:34)</a>:</h4>
<p>if indeed there are places that don't have access to it...</p>



<a name="128011596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011596">(Jun 13 2018 at 14:34)</a>:</h4>
<p>gonna try with Option first and see how it looks</p>



<a name="128011600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011600">(Jun 13 2018 at 14:34)</a>:</h4>
<p>it already seems too hacky :P</p>



<a name="128011617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011617">(Jun 13 2018 at 14:35)</a>:</h4>
<p>I wonder <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> if some refactoring is in order</p>



<a name="128011623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011623">(Jun 13 2018 at 14:35)</a>:</h4>
<p>in particular, I could imagine making a kind of "subcontext" struct that (a) has a pointer to the <code>MirBorrowckContext</code> but also a lot of other "environmental" information</p>



<a name="128011627"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011627" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011627">(Jun 13 2018 at 14:35)</a>:</h4>
<p>yep</p>



<a name="128011628"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011628" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011628">(Jun 13 2018 at 14:35)</a>:</h4>
<p>I feel like we thread a ton of parameters around...</p>



<a name="128011672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011672">(Jun 13 2018 at 14:36)</a>:</h4>
<p>I was thinking about the same, some kind of contextual object that has more information</p>



<a name="128011674"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011674" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011674">(Jun 13 2018 at 14:36)</a>:</h4>
<p>exactly</p>



<a name="128011678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128011678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128011678">(Jun 13 2018 at 14:36)</a>:</h4>
<p>it keeps growing, it sounds like it needs a struct</p>



<a name="128021004"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128021004" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128021004">(Jun 13 2018 at 17:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/spastorino/rust/commit/9aa9c0ca2f0c1f103f4272f8f353141b520124c3" target="_blank" title="https://github.com/spastorino/rust/commit/9aa9c0ca2f0c1f103f4272f8f353141b520124c3">https://github.com/spastorino/rust/commit/9aa9c0ca2f0c1f103f4272f8f353141b520124c3</a></p>



<a name="128021008"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128021008" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128021008">(Jun 13 2018 at 17:55)</a>:</h4>
<p>just to start discussing</p>



<a name="128021074"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128021074" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128021074">(Jun 13 2018 at 17:57)</a>:</h4>
<p>seems wrong though</p>



<a name="128022464"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022464" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022464">(Jun 13 2018 at 18:26)</a>:</h4>
<p>why does it seem wrong?</p>



<a name="128022533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022533">(Jun 13 2018 at 18:27)</a>:</h4>
<p>have you seen the stderr files?</p>



<a name="128022541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022541">(Jun 13 2018 at 18:27)</a>:</h4>
<p>I was inspecting some of the examples</p>



<a name="128022549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022549">(Jun 13 2018 at 18:27)</a>:</h4>
<p>and I have doubts</p>



<a name="128022597"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022597" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022597">(Jun 13 2018 at 18:28)</a>:</h4>
<p>but doesn't seem to be exactly what we want</p>



<a name="128022606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022606">(Jun 13 2018 at 18:28)</a>:</h4>
<p>anyway, I'd need to change the option thing</p>



<a name="128022609"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022609" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022609">(Jun 13 2018 at 18:28)</a>:</h4>
<p>and pass this rw struct from more places</p>



<a name="128022617"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022617" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022617">(Jun 13 2018 at 18:28)</a>:</h4>
<p>but that could make more examples to add the note</p>



<a name="128022621"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022621" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022621">(Jun 13 2018 at 18:28)</a>:</h4>
<p>which I'm neither sure if it's what we want</p>



<a name="128022850"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022850" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022850">(Jun 13 2018 at 18:32)</a>:</h4>
<p>well so it'd be good to highlight the examples that are giving you doubts</p>



<a name="128022871"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022871" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022871">(Jun 13 2018 at 18:33)</a>:</h4>
<p>the examples like this seem a bit odd</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">3</span><span class="p">;</span><span class="w"></span>
<span class="w">  </span><span class="o">&amp;</span><span class="n">z</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</pre></div>



<a name="128022877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022877">(Jun 13 2018 at 18:33)</a>:</h4>
<p>though I think that's actually an example where a note of this kind <em>would</em> be helpful;</p>



<a name="128022880"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022880" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022880">(Jun 13 2018 at 18:33)</a>:</h4>
<p>just maybe not <em>this</em> note</p>



<a name="128022894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022894">(Jun 13 2018 at 18:33)</a>:</h4>
<p>to do better there, I think we need to add more data— in particular we need to know <em>which</em> variable is being dropped</p>



<a name="128022897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022897">(Jun 13 2018 at 18:33)</a>:</h4>
<p>we have this information</p>



<a name="128022964"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022964" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022964">(Jun 13 2018 at 18:34)</a>:</h4>
<p><a href="https://github.com/spastorino/rust/commit/9aa9c0ca2f0c1f103f4272f8f353141b520124c3#diff-5b4d01d26caf43976125ba0f877e78c0R1054" target="_blank" title="https://github.com/spastorino/rust/commit/9aa9c0ca2f0c1f103f4272f8f353141b520124c3#diff-5b4d01d26caf43976125ba0f877e78c0R1054">here</a>, it would be <code>place_span.0</code></p>



<a name="128022984"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022984" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022984">(Jun 13 2018 at 18:35)</a>:</h4>
<p>if we knew which variable was being dropped (in the example above, it would be <code>z</code>) we could then check the scoping</p>



<a name="128022998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128022998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128022998">(Jun 13 2018 at 18:35)</a>:</h4>
<p>we might see here that <code>z</code> is in a subscope of <code>x</code> (the variable we have a reference to)</p>



<a name="128023020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128023020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128023020">(Jun 13 2018 at 18:35)</a>:</h4>
<p>in which case, we would say "note that variables are dropped at the end of the block in which they are declared" or something? seems a bit general, not sure how to express that this is a <em>subblock</em></p>



<a name="128023064"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128023064" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128023064">(Jun 13 2018 at 18:36)</a>:</h4>
<p>the note we are issuing would be reserved for variables in the <em>same</em> scope</p>



<a name="128023166"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128023166" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128023166">(Jun 13 2018 at 18:38)</a>:</h4>
<p>the scope info is available in the <code>source_info</code> field of a <code>LocalDecl</code></p>



<a name="128023178"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128023178" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128023178">(Jun 13 2018 at 18:38)</a>:</h4>
<p><a href="http://I%20was%20going%20to%20meet%20a%20friend%20of%20mine,%20that%20was%20the%20only%20day%20that%20works" target="_blank" title="http://I%20was%20going%20to%20meet%20a%20friend%20of%20mine,%20that%20was%20the%20only%20day%20that%20works">see here</a></p>



<a name="128028822"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128028822" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128028822">(Jun 13 2018 at 20:42)</a>:</h4>
<blockquote>
<p>just maybe not <em>this</em> note</p>
</blockquote>
<p><span class="emoji emoji-1f44d" title="+1">:+1:</span></p>



<a name="128029324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128029324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128029324">(Jun 13 2018 at 20:53)</a>:</h4>
<blockquote>
<p>the note we are issuing would be reserved for variables in the <em>same</em> scope</p>
</blockquote>
<p>I guess scope1 == scope2 works?</p>



<a name="128029346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128029346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128029346">(Jun 13 2018 at 20:53)</a>:</h4>
<blockquote>
<p>[see here] (I was going to meet a friend of mine, that was the only day that works)</p>
</blockquote>
<p>link is wrong, I see that you were going to meet a friend :P</p>



<a name="128037406"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128037406" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128037406">(Jun 14 2018 at 00:11)</a>:</h4>
<blockquote>
<p>I guess scope1 == scope2 works?</p>
</blockquote>
<p>probably</p>



<a name="128037413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128037413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128037413">(Jun 14 2018 at 00:11)</a>:</h4>
<blockquote>
<p>link is wrong, I see that you were going to meet a friend :P</p>
</blockquote>
<p>heh uh</p>



<a name="128037456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128037456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128037456">(Jun 14 2018 at 00:12)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/cd1105437cd433c12ae5132c9632e01d387b2384/src/librustc/mir/mod.rs#L371-L373" target="_blank" title="https://github.com/rust-lang/rust/blob/cd1105437cd433c12ae5132c9632e01d387b2384/src/librustc/mir/mod.rs#L371-L373">https://github.com/rust-lang/rust/blob/cd1105437cd433c12ae5132c9632e01d387b2384/src/librustc/mir/mod.rs#L371-L373</a></p>



<a name="128101366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128101366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128101366">(Jun 15 2018 at 04:04)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <span class="user-mention" data-user-id="116083">@pnkfelix</span> how do you get the scope given a <code>Place</code>?</p>



<a name="128101389"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128101389" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128101389">(Jun 15 2018 at 04:05)</a>:</h4>
<p>I would assume you would need to drill down to its underlying <code>Local</code>, and then map that via the <code>mir.local_decls[*local]</code> to a <code>mir::LocalDecl</code></p>



<a name="128101391"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128101391" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128101391">(Jun 15 2018 at 04:05)</a>:</h4>
<p>ya</p>



<a name="128101392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128101392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128101392">(Jun 15 2018 at 04:05)</a>:</h4>
<p>that's it</p>



<a name="128101432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128101432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> pnkfelix <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128101432">(Jun 15 2018 at 04:06)</a>:</h4>
<p>there are things called "scopes" that are fields in the <code>mir::LocalDecl</code>; I am not 100% sure if those are what you need for this issue though.</p>



<a name="128102424"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128102424" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128102424">(Jun 15 2018 at 04:43)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> for you to check tomorrow ... <a href="https://github.com/spastorino/rust/commit/a9213f3fedb8611472a08c543ca367d12106da61" target="_blank" title="https://github.com/spastorino/rust/commit/a9213f3fedb8611472a08c543ca367d12106da61">https://github.com/spastorino/rust/commit/a9213f3fedb8611472a08c543ca367d12106da61</a></p>



<a name="128102540"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128102540" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128102540">(Jun 15 2018 at 04:47)</a>:</h4>
<p>I guess I need the scope_tree, though, and call is_subscope there</p>



<a name="128119774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128119774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128119774">(Jun 15 2018 at 13:27)</a>:</h4>
<p>I don't think we can check for the <em>same</em> scope</p>



<a name="128119824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128119824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128119824">(Jun 15 2018 at 13:28)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> <a href="https://play.rust-lang.org/?gist=a936cc9e53ab356594be3c7e39721255&amp;version=nightly&amp;mode=debug" target="_blank" title="https://play.rust-lang.org/?gist=a936cc9e53ab356594be3c7e39721255&amp;version=nightly&amp;mode=debug">check out the MIR for this example</a>:</p>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">main</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">22</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">44</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>I see the following scopes</p>
<div class="codehilite"><pre><span></span>let mut _0: ();                      // return place
    scope 1 {
        scope 3 {
        }
        scope 4 {
            let _2: i32;                 // &quot;x&quot; in scope 4 at src/main.rs:3:9: 3:10
        }
    }
    scope 2 {
        let _1: i32;                     // &quot;y&quot; in scope 2 at src/main.rs:2:9: 2:10
    }
</pre></div>



<a name="128120094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128120094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128120094">(Jun 15 2018 at 13:34)</a>:</h4>
<p>I'm talking with <span class="user-mention" data-user-id="119009">@Eduard-Mihai Burtescu</span> about it over on Discord</p>



<a name="128120096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128120096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128120096">(Jun 15 2018 at 13:34)</a>:</h4>
<p>it's a bit confusing</p>



<a name="128120326"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128120326" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128120326">(Jun 15 2018 at 13:40)</a>:</h4>
<p>link to that conversation: <a href="https://discordapp.com/channels/442252698964721669/443151243398086667?jump=457175015394115585" target="_blank" title="https://discordapp.com/channels/442252698964721669/443151243398086667?jump=457175015394115585">link</a></p>



<a name="128125301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128125301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128125301">(Jun 15 2018 at 15:24)</a>:</h4>
<p>will check in a bit :)</p>



<a name="128245959"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128245959" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128245959">(Jun 18 2018 at 13:15)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> hey, sorry for being so absent last week</p>



<a name="128249826"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128249826" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128249826">(Jun 18 2018 at 14:35)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> no worries, I will be around in a while, we need to finish this ASAP :P</p>



<a name="128263263"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263263" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263263">(Jun 18 2018 at 18:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> around now?</p>



<a name="128263388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263388">(Jun 18 2018 at 18:59)</a>:</h4>
<p>yes</p>



<a name="128263407"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263407" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263407">(Jun 18 2018 at 18:59)</a>:</h4>
<p>I need to read Discord's log</p>



<a name="128263462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263462">(Jun 18 2018 at 19:00)</a>:</h4>
<p>so I think I can extract the relevant part though I don't know that I fully understand it</p>



<a name="128263468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263468">(Jun 18 2018 at 19:00)</a>:</h4>
<p>first off, apparently the current MIR output is misleading</p>



<a name="128263474"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263474" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263474">(Jun 18 2018 at 19:00)</a>:</h4>
<p>I've not tried to investigate more deeply but this is what <span class="user-mention" data-user-id="119009">@Eduard-Mihai Burtescu</span> wrote:</p>



<a name="128263585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263585">(Jun 18 2018 at 19:02)</a>:</h4>
<p>Case 1:</p>
<div class="codehilite"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>Case 2:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</pre></div>


<p>To distinguish:</p>
<ul>
<li>In case 1: in the first one, it's the other way around, with both scopes of <code>y</code> being nested only in the visibility scope of <code>x</code></li>
<li>In case 2: both scopes of <code>y</code> are nested within the source scope of <code>x</code>, and neither is nested in the visibility scope of <code>x</code></li>
</ul>



<a name="128263595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263595">(Jun 18 2018 at 19:02)</a>:</h4>
<p>so I guess there are two scopes: the visibility scope and.. the other one</p>



<a name="128263684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263684">(Jun 18 2018 at 19:04)</a>:</h4>
<p><code>in the first one, it's the other way around</code>, didn't follow this</p>



<a name="128263703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263703">(Jun 18 2018 at 19:04)</a>:</h4>
<p>both scopes of <code>y</code>, both?</p>



<a name="128263710"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263710" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263710">(Jun 18 2018 at 19:04)</a>:</h4>
<p>er, that's cause I reordered what he wrote</p>



<a name="128263711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263711">(Jun 18 2018 at 19:04)</a>:</h4>
<p>because he explained case 2 first</p>



<a name="128263714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263714">(Jun 18 2018 at 19:04)</a>:</h4>
<p>and then case 1 :)</p>



<a name="128263716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263716">(Jun 18 2018 at 19:04)</a>:</h4>
<p>:)</p>



<a name="128263718"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263718" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263718">(Jun 18 2018 at 19:04)</a>:</h4>
<p>let me look at the code a second</p>



<a name="128263763"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263763" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263763">(Jun 18 2018 at 19:05)</a>:</h4>
<p>there's actually some big comments</p>



<a name="128263767"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263767" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263767">(Jun 18 2018 at 19:05)</a>:</h4>
<p>hope they are up to date :)</p>



<a name="128263824"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263824" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263824">(Jun 18 2018 at 19:06)</a>:</h4>
<p>what is source scope and visibility scope?</p>



<a name="128263828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263828">(Jun 18 2018 at 19:06)</a>:</h4>
<p>these are the two scopes:<br>
- <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.source_info" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.source_info">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.source_info</a><br>
- <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope</a></p>



<a name="128263851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263851">(Jun 18 2018 at 19:07)</a>:</h4>
<p>ok I see</p>



<a name="128263855"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263855" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263855">(Jun 18 2018 at 19:07)</a>:</h4>
<p>the comments actually explain it pretty well</p>



<a name="128263857"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263857" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263857">(Jun 18 2018 at 19:07)</a>:</h4>
<p>so maybe take a look and see if it makes sense to you :)</p>



<a name="128263908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263908">(Jun 18 2018 at 19:08)</a>:</h4>
<p>what comments are you talking about?</p>



<a name="128263913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263913">(Jun 18 2018 at 19:08)</a>:</h4>
<p>in those links?</p>



<a name="128263922"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263922" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263922">(Jun 18 2018 at 19:08)</a>:</h4>
<p>or are you talking about comments in the source code?</p>



<a name="128263977"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263977" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263977">(Jun 18 2018 at 19:09)</a>:</h4>
<p>to update my summary of what <span class="user-mention" data-user-id="119009">@Eduard-Mihai Burtescu</span> wrote:</p>
<p>Case 1:</p>
<div class="codehilite"><pre><span></span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="p">;</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="p">;</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>


<p>Case 2:</p>
<div class="codehilite"><pre><span></span><span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"></span>
<span class="p">};</span><span class="w"></span>
</pre></div>


<p>To distinguish:</p>
<ul>
<li>In Case 1, the source scope of <code>y</code> is <strong>not</strong> nested within the source scope of <code>x</code>, but the visibility scope of <code>y</code> <strong>is</strong> nested within the visibility scope of <code>x</code></li>
<li>In Case 2, the source scope of <code>y</code> <strong>is</strong> nested within the source scope of <code>x</code></li>
</ul>
<p>So I think we want to issue the lint if:</p>
<ul>
<li>the <em>visibility scope</em> of the variable <code>y</code> being dropped <strong>is</strong> nested within the <em>visibility scope</em> of  the variable <code>x</code> being borrowed</li>
<li>but the <em>source scope</em> of <code>y</code> is <strong>not</strong> nested within the <em>source scope</em> of <code>x</code></li>
</ul>



<a name="128263987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128263987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128263987">(Jun 18 2018 at 19:09)</a>:</h4>
<blockquote>
<p>in those links?</p>
</blockquote>
<p>yes, in those links</p>



<a name="128264037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264037">(Jun 18 2018 at 19:10)</a>:</h4>
<p>reading the links</p>



<a name="128264048"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264048" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264048">(Jun 18 2018 at 19:10)</a>:</h4>
<p>to say more:</p>
<p>So I think we want to issue the lint if:</p>
<ul>
<li>the <em>visibility scope</em> of the variable <code>y</code> being dropped <strong>is</strong> nested within the <em>visibility scope</em> of  the variable <code>x</code> being borrowed<ul>
<li>this means that <code>x</code> is defined first, then <code>y</code></li>
</ul>
</li>
<li>but the <em>source scope</em> of <code>y</code> is <strong>not</strong> nested within the <em>source scope</em> of <code>x</code><ul>
<li>this means that <code>y</code> not defined inside of <code>x</code></li>
</ul>
</li>
</ul>



<a name="128264049"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264049" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264049">(Jun 18 2018 at 19:10)</a>:</h4>
<p>well the content in those links :')</p>



<a name="128264172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264172">(Jun 18 2018 at 19:13)</a>:</h4>
<p><code>The reason is that we want the local to be within the let-statement for lint purposes, but we want the local to be after the let-statement for names-in-scope purposes.</code></p>



<a name="128264181"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264181" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264181">(Jun 18 2018 at 19:13)</a>:</h4>
<p>why you need the local to be within the let-statement for lint purposes?</p>



<a name="128264366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264366">(Jun 18 2018 at 19:17)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="cp">#[allow(foo)]</span><span class="w"></span>
<span class="kd">let</span><span class="w"> </span><span class="n">x</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">  </span><span class="kd">let</span><span class="w"> </span><span class="n">y</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">..;</span><span class="w"> </span><span class="c1">// the `foo` lint is allowed here</span>
<span class="p">};</span><span class="w"></span>

<span class="kd">let</span><span class="w"> </span><span class="n">z</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="p">...;</span><span class="w"> </span><span class="c1">// but not here</span>
</pre></div>



<a name="128264447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264447">(Jun 18 2018 at 19:19)</a>:</h4>
<p>ahh I see</p>



<a name="128264450"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264450" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264450">(Jun 18 2018 at 19:19)</a>:</h4>
<p>yeah I care only about visibility scope</p>



<a name="128264508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264508">(Jun 18 2018 at 19:20)</a>:</h4>
<p>actually</p>



<a name="128264530"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264530" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264530">(Jun 18 2018 at 19:20)</a>:</h4>
<p>I guess yeah it suffices to look and see if the visibility scope of the one variable (being dropped) is enclosed within the one that was borrowed</p>



<a name="128264542"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264542" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264542">(Jun 18 2018 at 19:20)</a>:</h4>
<p>so you meant that source_info.scope is not visibility scope, I guess?</p>



<a name="128264543"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264543" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264543">(Jun 18 2018 at 19:20)</a>:</h4>
<p>so what I wrote is even more complex than is needed</p>



<a name="128264548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264548">(Jun 18 2018 at 19:21)</a>:</h4>
<p>it is not, there is <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope">a field called <code>visibility_scope</code></a></p>



<a name="128264558"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264558" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264558">(Jun 18 2018 at 19:21)</a>:</h4>
<p>ahh I see</p>



<a name="128264560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264560">(Jun 18 2018 at 19:21)</a>:</h4>
<p>ok</p>



<a name="128264571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264571">(Jun 18 2018 at 19:21)</a>:</h4>
<p>ok, will change this thing</p>



<a name="128264593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264593">(Jun 18 2018 at 19:21)</a>:</h4>
<p>and then to check if one of these things is a subscope of the other one I need <code>ScopeTree</code>, right?</p>



<a name="128264642"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264642" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264642">(Jun 18 2018 at 19:22)</a>:</h4>
<p>right :)</p>



<a name="128264646"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264646" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264646">(Jun 18 2018 at 19:22)</a>:</h4>
<p>ok, let me try all this</p>



<a name="128264658"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128264658" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128264658">(Jun 18 2018 at 19:22)</a>:</h4>
<p>pulling and building master :)</p>



<a name="128268094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268094">(Jun 18 2018 at 20:26)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> in order to pass scope_tree everywhere I need to spread that thing all over the place</p>



<a name="128268096"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268096" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268096">(Jun 18 2018 at 20:26)</a>:</h4>
<p>we really need like a context struct or something</p>



<a name="128268107"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268107" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268107">(Jun 18 2018 at 20:27)</a>:</h4>
<p>for now should I keep passing Option&lt;ScopeTree&gt; so when I don't have I just put None?</p>



<a name="128268136"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268136" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268136">(Jun 18 2018 at 20:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> are we not threading the MIR down I guess?</p>



<a name="128268139"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268139" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268139">(Jun 18 2018 at 20:27)</a>:</h4>
<p>or maybe use Option&lt;ScopeTree, WriteKind&gt;</p>



<a name="128268140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268140">(Jun 18 2018 at 20:27)</a>:</h4>
<p>I think we should just thread the MIR down if we're not already</p>



<a name="128268153"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268153" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268153">(Jun 18 2018 at 20:27)</a>:</h4>
<p>oh well</p>



<a name="128268154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268154">(Jun 18 2018 at 20:28)</a>:</h4>
<p>hmm</p>



<a name="128268199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268199">(Jun 18 2018 at 20:28)</a>:</h4>
<p>what is <code>ScopeTree</code> exactly?</p>



<a name="128268210"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268210" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268210">(Jun 18 2018 at 20:28)</a>:</h4>
<p>we could modify the <code>WriteKind</code> to carry the local variable info we need, if it's not otherwise available</p>



<a name="128268233"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268233" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268233">(Jun 18 2018 at 20:28)</a>:</h4>
<p>also, I don't think we want a scope tree at all</p>



<a name="128268236"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268236" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268236">(Jun 18 2018 at 20:28)</a>:</h4>
<p>maybe I am confused :)</p>



<a name="128268244"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268244" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268244">(Jun 18 2018 at 20:29)</a>:</h4>
<p>but this search doesn't seem to turn up any related data types <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/?search=scopetree" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/?search=scopetree">https://doc.rust-lang.org/nightly/nightly-rustc/rustc/?search=scopetree</a></p>



<a name="128268336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268336">(Jun 18 2018 at 20:30)</a>:</h4>
<p>so ...</p>



<a name="128268358"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268358" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268358">(Jun 18 2018 at 20:30)</a>:</h4>
<p>I thought that was the thing you needed to call <code>subscope</code></p>



<a name="128268377"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268377" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268377">(Jun 18 2018 at 20:31)</a>:</h4>
<p>maybe that thing is completely unrelated to what I'm doing? :P</p>



<a name="128268388"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268388" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268388">(Jun 18 2018 at 20:31)</a>:</h4>
<p>hmmm I think so</p>



<a name="128268392"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268392" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268392">(Jun 18 2018 at 20:31)</a>:</h4>
<p>it's related to regions</p>



<a name="128268402"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268402" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268402">(Jun 18 2018 at 20:31)</a>:</h4>
<p>there are multiple "scope-like" things</p>



<a name="128268447"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268447" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268447">(Jun 18 2018 at 20:32)</a>:</h4>
<p>can you send me a link to the latest code?</p>



<a name="128268452"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268452" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268452">(Jun 18 2018 at 20:32)</a>:</h4>
<p>so I can get some idea what you have available :)</p>



<a name="128268498"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268498" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268498">(Jun 18 2018 at 20:33)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772" target="_blank" title="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772">https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772</a></p>



<a name="128268524"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268524" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268524">(Jun 18 2018 at 20:33)</a>:</h4>
<p>ok so you have the MIR in the <code>mir</code> variable</p>



<a name="128268570"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268570" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268570">(Jun 18 2018 at 20:34)</a>:</h4>
<p>i.e., <a href="https://github.com/spastorino/rust/blob/0a6bcc89d80b6412e11bc0ebde51c194a24e4772/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L34" target="_blank" title="https://github.com/spastorino/rust/blob/0a6bcc89d80b6412e11bc0ebde51c194a24e4772/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L34">here</a></p>



<a name="128268575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268575">(Jun 18 2018 at 20:34)</a>:</h4>
<p>yes</p>



<a name="128268583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268583">(Jun 18 2018 at 20:34)</a>:</h4>
<p>so we should be able to extract the <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html"><code>LocalDecl</code></a> for the two local variables involved</p>



<a name="128268595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268595">(Jun 18 2018 at 20:34)</a>:</h4>
<p>e.g., <code>&amp;mir.local_decls[local]</code></p>



<a name="128268625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268625">(Jun 18 2018 at 20:35)</a>:</h4>
<p>yep that's already done</p>



<a name="128268632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268632">(Jun 18 2018 at 20:35)</a>:</h4>
<p><a href="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR49" target="_blank" title="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR49">https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR49</a></p>



<a name="128268676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268676">(Jun 18 2018 at 20:36)</a>:</h4>
<p><a href="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR50" target="_blank" title="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR50">https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR50</a></p>



<a name="128268678"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268678" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268678">(Jun 18 2018 at 20:36)</a>:</h4>
<p>the <code>local</code> we <a href="https://github.com/spastorino/rust/blob/0a6bcc89d80b6412e11bc0ebde51c194a24e4772/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L70" target="_blank" title="https://github.com/spastorino/rust/blob/0a6bcc89d80b6412e11bc0ebde51c194a24e4772/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs#L70">extract from <code>Cause::DropVar</code></a> is the one being dropped -- the <code>x</code> in our examples</p>



<a name="128268690"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268690" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268690">(Jun 18 2018 at 20:36)</a>:</h4>
<p>ah right ok</p>



<a name="128268698"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268698" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268698">(Jun 18 2018 at 20:36)</a>:</h4>
<p>so we just need to check basically if the one visibility scope is a subscope of the other</p>



<a name="128268705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268705">(Jun 18 2018 at 20:36)</a>:</h4>
<p>yes</p>



<a name="128268706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268706">(Jun 18 2018 at 20:36)</a>:</h4>
<p>I need to change this <a href="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR52" target="_blank" title="https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR52">https://github.com/spastorino/rust/commit/0a6bcc89d80b6412e11bc0ebde51c194a24e4772#diff-fe005d3dcf77fde8f189617b2599e10eR52</a></p>



<a name="128268733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268733">(Jun 18 2018 at 20:37)</a>:</h4>
<p>the field <a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.Mir.html#structfield.source_scopes" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.Mir.html#structfield.source_scopes"><code>source_scopes</code></a> contains the info for each scope</p>



<a name="128268738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268738">(Jun 18 2018 at 20:37)</a>:</h4>
<p>I don't know if there is a helper to check for subscopes</p>



<a name="128268741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268741">(Jun 18 2018 at 20:37)</a>:</h4>
<p>but we could add one if not</p>



<a name="128268752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268752">(Jun 18 2018 at 20:37)</a>:</h4>
<p>I don't see any such helper</p>



<a name="128268813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268813">(Jun 18 2018 at 20:38)</a>:</h4>
<p>presumably we would fetch the parent data for the "smaller scope" and iterate up the chain (<a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.SourceScopeData.html#structfield.parent_scope" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.SourceScopeData.html#structfield.parent_scope">parent data is in this field</a>)</p>



<a name="128268815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268815">(Jun 18 2018 at 20:38)</a>:</h4>
<p>but wasn't source scope different to visibility scope?</p>



<a name="128268834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268834">(Jun 18 2018 at 20:38)</a>:</h4>
<p>hmm the names are maybe a bit confusing <em>but</em></p>



<a name="128268837"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268837" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268837">(Jun 18 2018 at 20:38)</a>:</h4>
<p>the <code>SourceScope</code> type is used for both of the fields</p>



<a name="128268846"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268846" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268846">(Jun 18 2018 at 20:39)</a>:</h4>
<p><a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.LocalDecl.html#structfield.visibility_scope"><code>visibility_scope: SourceScope</code></a></p>



<a name="128268860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268860">(Jun 18 2018 at 20:39)</a>:</h4>
<p>probably the fields should be named <code>decl_scope</code> and <code>visibility_scope</code></p>



<a name="128268863"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268863" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268863">(Jun 18 2018 at 20:39)</a>:</h4>
<p>i.e., there are two scopes associated with a variable</p>



<a name="128268873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268873">(Jun 18 2018 at 20:39)</a>:</h4>
<p>but both of them are scopes</p>



<a name="128268894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128268894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128268894">(Jun 18 2018 at 20:40)</a>:</h4>
<p>put another way, there is one tree of scopes, and the decl-scope and the visibility-scope both reference into it</p>



<a name="128269752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269752">(Jun 18 2018 at 20:54)</a>:</h4>
<blockquote>
<p>presumably we would fetch the parent data for the "smaller scope" and iterate up the chain (<a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.SourceScopeData.html#structfield.parent_scope" target="_blank" title="https://doc.rust-lang.org/nightly/nightly-rustc/rustc/mir/struct.SourceScopeData.html#structfield.parent_scope">parent data is in this field</a>)</p>
</blockquote>
<p>you meant, to start from the smaller and go up until it matches the bigger one?</p>



<a name="128269780"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269780" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269780">(Jun 18 2018 at 20:54)</a>:</h4>
<p>how do you know which is the smaller one?</p>



<a name="128269791"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269791" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269791">(Jun 18 2018 at 20:55)</a>:</h4>
<p>well we know we want to test if one is smaller than the other</p>



<a name="128269793"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269793" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269793">(Jun 18 2018 at 20:55)</a>:</h4>
<p>well you know :)</p>



<a name="128269795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269795">(Jun 18 2018 at 20:55)</a>:</h4>
<p>so we'd start from that one</p>



<a name="128269806"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269806" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269806">(Jun 18 2018 at 20:55)</a>:</h4>
<p>yep</p>



<a name="128269808"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269808" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269808">(Jun 18 2018 at 20:55)</a>:</h4>
<p>in particular, we want to start from the one that is being dropped</p>



<a name="128269830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128269830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128269830">(Jun 18 2018 at 20:55)</a>:</h4>
<p>(since the idea would be that if you reorder that w/r/t the other one, you would make it bigger...)</p>



<a name="128270577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270577">(Jun 18 2018 at 21:12)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> trying this thing</p>



<a name="128270579"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270579" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270579">(Jun 18 2018 at 21:12)</a>:</h4>
<p>+1</p>



<a name="128270581"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270581" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270581">(Jun 18 2018 at 21:12)</a>:</h4>
<p>so ... I iterate to the parent</p>



<a name="128270583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270583">(Jun 18 2018 at 21:12)</a>:</h4>
<p>and check for span?</p>



<a name="128270591"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270591" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270591">(Jun 18 2018 at 21:12)</a>:</h4>
<p>I mean, if parent span is equal to the other scope span?</p>



<a name="128270676"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270676" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270676">(Jun 18 2018 at 21:14)</a>:</h4>
<p>I would never look at the span</p>



<a name="128270680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270680">(Jun 18 2018 at 21:14)</a>:</h4>
<p>I would rather add a method to <code>Mir</code> like</p>



<a name="128270719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270719">(Jun 18 2018 at 21:15)</a>:</h4>
<div class="codehilite"><pre><span></span><span class="k">fn</span> <span class="nf">is_sub_scope</span><span class="p">(</span><span class="o">&amp;</span><span class="bp">self</span><span class="p">,</span><span class="w"> </span><span class="k">mut</span><span class="w"> </span><span class="n">sub</span>: <span class="nc">SourceScope</span><span class="p">,</span><span class="w"> </span><span class="n">sup</span>: <span class="nc">SourceScope</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">loop</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="k">if</span><span class="w"> </span><span class="n">sub</span><span class="w"> </span><span class="o">==</span><span class="w"> </span><span class="n">sup</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">true</span><span class="p">;</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
<span class="w">        </span><span class="k">match</span><span class="w"> </span><span class="bp">self</span><span class="p">.</span><span class="n">scope_info</span><span class="p">[</span><span class="n">sub</span><span class="p">].</span><span class="n">parent</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">            </span><span class="nb">None</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="k">return</span><span class="w"> </span><span class="kc">false</span><span class="p">,</span><span class="w"></span>
<span class="w">            </span><span class="nb">Some</span><span class="p">(</span><span class="n">p</span><span class="p">)</span><span class="w"> </span><span class="o">=&gt;</span><span class="w"> </span><span class="n">sub</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">p</span><span class="p">,</span><span class="w"></span>
<span class="w">        </span><span class="p">}</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</pre></div>



<a name="128270728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270728">(Jun 18 2018 at 21:15)</a>:</h4>
<p>and then you can ask <code>if mir.is_sub_scope(a, b) { ... }</code></p>



<a name="128270785"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270785" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270785">(Jun 18 2018 at 21:16)</a>:</h4>
<p>yeah, was doing something like that</p>



<a name="128270795"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270795" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270795">(Jun 18 2018 at 21:16)</a>:</h4>
<p>figured after asking that I needed <code>==</code></p>



<a name="128270928"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270928" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270928">(Jun 18 2018 at 21:19)</a>:</h4>
<p>yeah, main thing is you can just compare the indices</p>



<a name="128270930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128270930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128270930">(Jun 18 2018 at 21:19)</a>:</h4>
<p>you don't need to look at the spans</p>



<a name="128271097"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128271097" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128271097">(Jun 18 2018 at 21:23)</a>:</h4>
<p><span class="emoji emoji-1f44d" title="+1">:+1:</span></p>



<a name="128271100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128271100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128271100">(Jun 18 2018 at 21:23)</a>:</h4>
<p>this is compiling, etc</p>



<a name="128271106"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128271106" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128271106">(Jun 18 2018 at 21:24)</a>:</h4>
<p>hope it works and will open a PR soon</p>



<a name="128273346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128273346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128273346">(Jun 18 2018 at 22:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> still not working :(</p>



<a name="128273598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128273598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128273598">(Jun 18 2018 at 22:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f" target="_blank" title="https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f">https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f</a></p>



<a name="128273630"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128273630" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128273630">(Jun 18 2018 at 22:21)</a>:</h4>
<p>what's this <a href="https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f#diff-ae6caad4b0eb05799bbbd3eeb98f64d7R13" target="_blank" title="https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f#diff-ae6caad4b0eb05799bbbd3eeb98f64d7R13">https://github.com/spastorino/rust/commit/30a7e60a1f5b9c806a6d476685530386ca05ca7f#diff-ae6caad4b0eb05799bbbd3eeb98f64d7R13</a> stuff?</p>



<a name="128273694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128273694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128273694">(Jun 18 2018 at 22:23)</a>:</h4>
<p>ahh I see, compiler is ICEing</p>



<a name="128277170"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128277170" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128277170">(Jun 18 2018 at 23:52)</a>:</h4>
<p>any idea why?</p>



<a name="128278665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278665">(Jun 19 2018 at 00:34)</a>:</h4>
<p>no</p>



<a name="128278677"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278677" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278677">(Jun 19 2018 at 00:35)</a>:</h4>
<p>try running the test with <code>RUST_BACKTRACE=1</code>?</p>



<a name="128278825"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278825" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278825">(Jun 19 2018 at 00:39)</a>:</h4>
<p>have done that already</p>



<a name="128278830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278830">(Jun 19 2018 at 00:39)</a>:</h4>
<p>let me paste the output</p>



<a name="128278885"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278885" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278885">(Jun 19 2018 at 00:40)</a>:</h4>
<div class="codehilite"><pre><span></span>[santiago@archlinux rust1 (diagnostic-suggest-drop-in-reverse)]$ RUST_BACKTRACE=1 rustc +stage1 src/test/ui/error-codes/E0657.rs
error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
  --&gt; src/test/ui/error-codes/E0657.rs:19:31
   |
19 |     -&gt; Box&lt;for&lt;&#39;a&gt; Id&lt;impl Lt&lt;&#39;a&gt;&gt;&gt;
   |                               ^^

error[E0657]: `impl Trait` can only capture lifetimes bound at the fn or impl level
  --&gt; src/test/ui/error-codes/E0657.rs:28:35
   |
28 |         -&gt; Box&lt;for&lt;&#39;a&gt; Id&lt;impl Lt&lt;&#39;a&gt;&gt;&gt;
   |                                   ^^

thread &#39;main&#39; panicked at &#39;assertion failed: !erased_self_ty.has_escaping_regions()&#39;, librustc/ty/util.rs:369:9
stack backtrace:
   0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
             at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
   1: std::sys_common::backtrace::print
             at libstd/sys_common/backtrace.rs:71
             at libstd/sys_common/backtrace.rs:59
   2: std::panicking::default_hook::{{closure}}
             at libstd/panicking.rs:211
   3: std::panicking::default_hook
             at libstd/panicking.rs:227
   4: rustc::util::common::panic_hook
             at librustc/util/common.rs:54
   5: std::panicking::rust_panic_with_hook
             at libstd/panicking.rs:515
   6: std::panicking::begin_panic
             at libstd/panicking.rs:445
   7: rustc::ty::util::&lt;impl rustc::ty::context::TyCtxt&lt;&#39;a, &#39;gcx, &#39;tcx&gt;&gt;::required_region_bounds
             at librustc/ty/util.rs:369
   8: rustc::infer::anon_types::Instantiator::fold_anon_ty
             at librustc/infer/anon_types/mod.rs:748
   9: &lt;rustc::ty::fold::BottomUpFolder&lt;&#39;a, &#39;gcx, &#39;tcx, F&gt; as rustc::ty::fold::TypeFolder&lt;&#39;gcx, &#39;tcx&gt;&gt;::fold_ty
             at ./src/librustc/infer/anon_types/mod.rs:704
             at ./src/librustc/ty/fold.rs:203
  10: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::TyS&lt;&#39;tcx&gt;&gt;::fold_with
             at ./src/librustc/ty/structural_impls.rs:885
  11: core::ops::function::impls::&lt;impl core::ops::function::FnOnce&lt;A&gt; for &amp;&#39;a mut F&gt;::call_once
             at ./src/librustc/ty/subst.rs:155
             at ./src/librustc/ty/fold.rs:58
             at ./src/librustc/ty/subst.rs:327
             at ./src/libcore/ops/function.rs:271
  12: &lt;rustc_data_structures::array_vec::ArrayVec&lt;A&gt; as core::iter::traits::Extend&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::extend
             at ./src/libcore/option.rs:414
             at ./src/libcore/iter/mod.rs:1326
             at ./src/librustc_data_structures/array_vec.rs:197
  13: &lt;rustc_data_structures::accumulate_vec::AccumulateVec&lt;A&gt; as core::iter::traits::FromIterator&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::from_iter
             at ./src/librustc_data_structures/accumulate_vec.rs:113
  14: rustc::ty::subst::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::Slice&lt;rustc::ty::subst::Kind&lt;&#39;tcx&gt;&gt;&gt;::super_fold_with
             at ./src/libcore/iter/iterator.rs:1398
             at ./src/librustc/ty/subst.rs:327
  15: rustc::ty::fold::TypeFoldable::fold_with
             at ./src/librustc/ty/fold.rs:58
  16: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for rustc::ty::sty::ExistentialPredicate&lt;&#39;tcx&gt;&gt;::super_fold_with
             at ./src/librustc/macros.rs:314
             at ./src/librustc/ty/fold.rs:58
             at ./src/librustc/macros.rs:394
  17: rustc::ty::fold::TypeFoldable::fold_with
             at ./src/librustc/ty/fold.rs:58
  18: core::ops::function::impls::&lt;impl core::ops::function::FnOnce&lt;A&gt; for &amp;&#39;a mut F&gt;::call_once
             at ./src/librustc/ty/structural_impls.rs:749
             at ./src/libcore/ops/function.rs:271
  19: &lt;rustc_data_structures::array_vec::ArrayVec&lt;A&gt; as core::iter::traits::Extend&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::extend
             at ./src/libcore/option.rs:414
             at ./src/libcore/iter/mod.rs:1326
             at ./src/librustc_data_structures/array_vec.rs:197
  20: &lt;rustc_data_structures::accumulate_vec::AccumulateVec&lt;A&gt; as core::iter::traits::FromIterator&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::from_iter
             at ./src/librustc_data_structures/accumulate_vec.rs:113
  21: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::Slice&lt;rustc::ty::sty::ExistentialPredicate&lt;&#39;tcx&gt;&gt;&gt;::super_fold_with
             at ./src/libcore/iter/iterator.rs:1398
             at ./src/librustc/ty/structural_impls.rs:749
  22: rustc::ty::fold::TypeFoldable::fold_with
             at ./src/librustc/ty/fold.rs:58
  23: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for rustc::ty::sty::Binder&lt;T&gt;&gt;::super_fold_with
             at ./src/librustc/ty/structural_impls.rs:727
             at ./src/librustc/ty/sty.rs:788
             at ./src/librustc/ty/sty.rs:782
             at ./src/librustc/ty/structural_impls.rs:727
  24: rustc::ty::fold::TypeFolder::fold_binder
             at ./src/librustc/ty/fold.rs:152
  25: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for rustc::ty::sty::Binder&lt;T&gt;&gt;::fold_with
             at ./src/librustc/ty/structural_impls.rs:731
  26: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::TyS&lt;&#39;tcx&gt;&gt;::super_fold_with
             at ./src/librustc/ty/structural_impls.rs:853
  27: &lt;rustc::ty::fold::BottomUpFolder&lt;&#39;a, &#39;gcx, &#39;tcx, F&gt; as rustc::ty::fold::TypeFolder&lt;&#39;gcx, &#39;tcx&gt;&gt;::fold_ty
             at ./src/librustc/ty/fold.rs:202
  28: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::TyS&lt;&#39;tcx&gt;&gt;::fold_with
             at ./src/librustc/ty/structural_impls.rs:885
  29: core::ops::function::impls::&lt;impl core::ops::function::FnOnce&lt;A&gt; for &amp;&#39;a mut F&gt;::call_once
             at ./src/librustc/ty/subst.rs:155
             at ./src/librustc/ty/fold.rs:58
             at ./src/librustc/ty/subst.rs:327
             at ./src/libcore/ops/function.rs:271
  30: &lt;rustc_data_structures::array_vec::ArrayVec&lt;A&gt; as core::iter::traits::Extend&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::extend
             at ./src/libcore/option.rs:414
             at ./src/libcore/iter/mod.rs:1326
             at ./src/librustc_data_structures/array_vec.rs:197
  31: &lt;rustc_data_structures::accumulate_vec::AccumulateVec&lt;A&gt; as core::iter::traits::FromIterator&lt;&lt;A as rustc_data_structures::array_vec::Array&gt;::Element&gt;&gt;::from_iter
             at ./src/librustc_data_structures/accumulate_vec.rs:113
  32: rustc::ty::subst::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::Slice&lt;rustc::ty::subst::Kind&lt;&#39;tcx&gt;&gt;&gt;::super_fold_with
             at ./src/libcore/iter/iterator.rs:1398
             at ./src/librustc/ty/subst.rs:327
  33: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::TyS&lt;&#39;tcx&gt;&gt;::super_fold_with
             at ./src/librustc/ty/fold.rs:58
             at ./src/librustc/ty/structural_impls.rs:851
  34: &lt;rustc::ty::fold::BottomUpFolder&lt;&#39;a, &#39;gcx, &#39;tcx, F&gt; as rustc::ty::fold::TypeFolder&lt;&#39;gcx, &#39;tcx&gt;&gt;::fold_ty
             at ./src/librustc/ty/fold.rs:202
  35: rustc::ty::structural_impls::&lt;impl rustc::ty::fold::TypeFoldable&lt;&#39;tcx&gt; for &amp;&#39;tcx rustc::ty::TyS&lt;&#39;tcx&gt;&gt;::fold_with
             at ./src/librustc/ty/structural_impls.rs:885
  36: rustc::infer::anon_types::Instantiator::instantiate_anon_types_in_map
             at ./src/librustc/infer/anon_types/mod.rs:654
  37: rustc::infer::anon_types::&lt;impl rustc::infer::InferCtxt&lt;&#39;a, &#39;gcx, &#39;tcx&gt;&gt;::instantiate_anon_types
             at ./src/librustc/infer/anon_types/mod.rs:127
  38: rustc_typeck::check::FnCtxt::instantiate_anon_types_from_return_value
             at librustc_typeck/check/mod.rs:2093
  39: rustc_typeck::check::check_fn
             at librustc_typeck/check/mod.rs:1022
  40: rustc::ty::context::tls::set_tlv
             at librustc_typeck/check/mod.rs:849
             at librustc_typeck/check/mod.rs:608
             at ./src/librustc/infer/mod.rs:453
             at ./src/librustc/ty/context.rs:1483
             at ./src/librustc/ty/context.rs:1829
             at ./src/librustc/ty/context.rs:1768
  41: rustc::ty::context::tls::with_context_opt
             at ./src/librustc/ty/context.rs:1828
             at ./src/librustc/ty/context.rs:1482
             at ./src/librustc/ty/context.rs:1929
             at ./src/librustc/ty/context.rs:1913
             at ./src/librustc/ty/context.rs:1904
  42: rustc::ty::context::tls::with_related_context
             at ./src/librustc/ty/context.rs:1913
             at ./src/librustc/ty/context.rs:1924
  43: rustc::ty::context::GlobalCtxt::enter_local
             at ./src/librustc/ty/context.rs:1475
  44: rustc::infer::InferCtxtBuilder::enter
             at ./src/librustc/infer/mod.rs:453
  45: rustc_typeck::check::InheritedBuilder::enter
             at librustc_typeck/check/mod.rs:608
  46: rustc_typeck::check::typeck_tables_of
             at librustc_typeck/check/mod.rs:833
  47: rustc::ty::query::__query_compute::typeck_tables_of
             at librustc/ty/query/plumbing.rs:783
             at librustc/ty/query/plumbing.rs:752
  48: rustc::ty::query::&lt;impl rustc::ty::query::config::QueryAccessors&lt;&#39;tcx&gt; for rustc::ty::query::queries::typeck_tables_of&lt;&#39;tcx&gt;&gt;::compute
             at librustc/ty/query/plumbing.rs:781
  49: rustc::dep_graph::graph::DepGraph::with_task_impl
             at librustc/dep_graph/graph.rs:341
  50: rustc::dep_graph::graph::DepGraph::with_task
             at librustc/dep_graph/graph.rs:207
  51: rustc::ty::context::tls::set_tlv
             at librustc/ty/query/plumbing.rs:533
             at librustc/ty/query/plumbing.rs:203
             at librustc/ty/context.rs:1829
             at librustc/ty/context.rs:1768
  52: rustc::ty::context::tls::with_context_opt
             at librustc/ty/context.rs:1828
             at librustc/ty/query/plumbing.rs...
</pre></div>



<a name="128278899"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278899" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278899">(Jun 19 2018 at 00:41)</a>:</h4>
<p>haven't investigated yet</p>



<a name="128278901"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278901" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278901">(Jun 19 2018 at 00:41)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> ^^^</p>



<a name="128278941"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128278941" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128278941">(Jun 19 2018 at 00:42)</a>:</h4>
<p>maybe better this <a href="https://gist.github.com/spastorino/b589e884798f72c75679d45ea91ecae5" target="_blank" title="https://gist.github.com/spastorino/b589e884798f72c75679d45ea91ecae5">https://gist.github.com/spastorino/b589e884798f72c75679d45ea91ecae5</a></p>



<a name="128280053"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128280053" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128280053">(Jun 19 2018 at 01:17)</a>:</h4>
<p>ok, it's a thing that's happening on master</p>



<a name="128281015"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128281015" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128281015">(Jun 19 2018 at 01:49)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> this would be the thing <a href="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff" target="_blank" title="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff">https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff</a></p>



<a name="128281020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128281020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128281020">(Jun 19 2018 at 01:49)</a>:</h4>
<p>need to check if all the notes are on examples that make sense</p>



<a name="128292743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128292743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128292743">(Jun 19 2018 at 08:14)</a>:</h4>
<blockquote>
<p>ok, it's a thing that's happening on master</p>
</blockquote>
<p>huh?</p>



<a name="128292777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128292777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128292777">(Jun 19 2018 at 08:15)</a>:</h4>
<p>actually, I think maybe I am seeing it too</p>



<a name="128305027"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305027" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305027">(Jun 19 2018 at 13:40)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> we are still alerting in this kind of cases <a href="https://github.com/spastorino/rust/blob/37a565546509b601f356e2d2136bab431c46beff/src/test/ui/issue-46471-1.rs" target="_blank" title="https://github.com/spastorino/rust/blob/37a565546509b601f356e2d2136bab431c46beff/src/test/ui/issue-46471-1.rs">https://github.com/spastorino/rust/blob/37a565546509b601f356e2d2136bab431c46beff/src/test/ui/issue-46471-1.rs</a></p>



<a name="128305037"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305037" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305037">(Jun 19 2018 at 13:40)</a>:</h4>
<p>see <a href="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#diff-f471045f63f2df09085b887aa7dd4644R26" target="_blank" title="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#diff-f471045f63f2df09085b887aa7dd4644R26">https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#diff-f471045f63f2df09085b887aa7dd4644R26</a></p>



<a name="128305832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305832">(Jun 19 2018 at 13:57)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> huh.</p>



<a name="128305909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305909">(Jun 19 2018 at 13:58)</a>:</h4>
<p>if I were you, I would add <code>debug!</code> and print out</p>
<ul>
<li>both of the scopes</li>
<li>whether the visibility scope of Borrowed is a subscope of the Dropped variable</li>
<li>whether the visibility scope of Dropped is a subscope of the Borrowed variable</li>
<li>whether the source scope of Borrowed is a subscope of the Dropped variable</li>
<li>whether the source scope of Dropped is a subscope of the Borrowed variable</li>
</ul>
<p>and then try a few examples to see what we should be looking for :)</p>



<a name="128305911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305911">(Jun 19 2018 at 13:58)</a>:</h4>
<p>maybe we are confused</p>



<a name="128305930"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305930" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305930">(Jun 19 2018 at 13:59)</a>:</h4>
<p>I would also print out the locals themselves</p>



<a name="128305942"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128305942" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128305942">(Jun 19 2018 at 13:59)</a>:</h4>
<p>so we can check that we are plumbing through the values we <em>think</em> we are plumbing through</p>



<a name="128308691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308691">(Jun 19 2018 at 14:52)</a>:</h4>
<p>hey, back, so ...</p>



<a name="128308716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308716">(Jun 19 2018 at 14:52)</a>:</h4>
<p>but the thing is ...</p>



<a name="128308732"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308732" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308732">(Jun 19 2018 at 14:53)</a>:</h4>
<div class="codehilite"><pre><span></span>fn main() {
    let y = {
        let mut z = 0;
        &amp;mut z
    };
    //~^^ ERROR `z` does not live long enough (Ast) [E0597]
    //~| ERROR `z` does not live long enough (Mir) [E0597]
    println!(&quot;{}&quot;, y);
}
</pre></div>



<a name="128308740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308740">(Jun 19 2018 at 14:53)</a>:</h4>
<p>visibility scope of the borrowed z is a subscope of y</p>



<a name="128308743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308743">(Jun 19 2018 at 14:53)</a>:</h4>
<p>and that's what I'm checking</p>



<a name="128308745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308745">(Jun 19 2018 at 14:53)</a>:</h4>
<p>so this is right</p>



<a name="128308750"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308750" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308750">(Jun 19 2018 at 14:53)</a>:</h4>
<p>unsure if it's what we wanted</p>



<a name="128308752"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308752" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308752">(Jun 19 2018 at 14:53)</a>:</h4>
<p>because we don't want to alert in this case</p>



<a name="128308831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308831">(Jun 19 2018 at 14:55)</a>:</h4>
<p>I think you should dump out all the relationships</p>



<a name="128308909"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308909" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308909">(Jun 19 2018 at 14:57)</a>:</h4>
<p>I do not believe that the visibility scope of <code>z</code> <em>should</em> be a subscope of the visibility scope of <code>y</code></p>



<a name="128308911"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308911" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308911">(Jun 19 2018 at 14:57)</a>:</h4>
<p>so something seems fishy</p>



<a name="128308912"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308912" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308912">(Jun 19 2018 at 14:57)</a>:</h4>
<p>like, there is no point in the program where <code>y</code> and <code>z</code> are both ins cope</p>



<a name="128308913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128308913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128308913">(Jun 19 2018 at 14:57)</a>:</h4>
<p>so something is awry</p>



<a name="128309596"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309596" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309596">(Jun 19 2018 at 15:07)</a>:</h4>
<p>ok</p>



<a name="128309600"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309600" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309600">(Jun 19 2018 at 15:07)</a>:</h4>
<p>let me check that</p>



<a name="128309705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309705">(Jun 19 2018 at 15:09)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> this is why I was suggesting just dumping All The Things</p>



<a name="128309709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309709">(Jun 19 2018 at 15:09)</a>:</h4>
<p>so we can kind of see what's going on</p>



<a name="128309796"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309796" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309796">(Jun 19 2018 at 15:11)</a>:</h4>
<p>yes</p>



<a name="128309797"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128309797" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128309797">(Jun 19 2018 at 15:11)</a>:</h4>
<p>doing that</p>



<a name="128310680"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310680" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310680">(Jun 19 2018 at 15:27)</a>:</h4>
<div class="codehilite"><pre><span></span>DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: visibility local_scope=scope[0]
DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: visibility borrowed_local_scope=scope[3]
DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: borrowed_local_scope is a sub scope of local_scope
DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: source local_scope=scope[0]
DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: source borrowed_local_scope=scope[4]
DEBUG 2018-06-19T15:26:16Z: rustc_mir::borrow_check::nll::explain_borrow: source_borrowed_local_scope is a sub scope of source_local_scope
</pre></div>



<a name="128310733"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310733" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310733">(Jun 19 2018 at 15:28)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> visibility and source scopes of the borrowed thing are subscopes of the local thing</p>



<a name="128310738"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310738" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310738">(Jun 19 2018 at 15:28)</a>:</h4>
<p>can you try two examples?</p>



<a name="128310740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310740">(Jun 19 2018 at 15:28)</a>:</h4>
<p>i.e., also an example where we <em>want</em> it to fire?</p>



<a name="128310744"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310744" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310744">(Jun 19 2018 at 15:28)</a>:</h4>
<p>also, what is the MIR in this case?</p>



<a name="128310751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310751">(Jun 19 2018 at 15:29)</a>:</h4>
<p>yes</p>



<a name="128310755"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310755" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310755">(Jun 19 2018 at 15:29)</a>:</h4>
<p>finally, can you also add other bits of log — notably, what are the local variables in question?</p>



<a name="128310761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310761">(Jun 19 2018 at 15:29)</a>:</h4>
<p>yes</p>



<a name="128310764"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310764" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310764">(Jun 19 2018 at 15:29)</a>:</h4>
<p>-Zmir-dump, right?</p>



<a name="128310773"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310773" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310773">(Jun 19 2018 at 15:29)</a>:</h4>
<p><code>-Zdump-mir=nll</code> I think</p>



<a name="128310775"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310775" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310775">(Jun 19 2018 at 15:29)</a>:</h4>
<p>at  least that is what my fingers want to type</p>



<a name="128310776"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310776" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310776">(Jun 19 2018 at 15:29)</a>:</h4>
<p>ok</p>



<a name="128310782"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310782" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310782">(Jun 19 2018 at 15:30)</a>:</h4>
<p>hehehe</p>



<a name="128310831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128310831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128310831">(Jun 19 2018 at 15:30)</a>:</h4>
<p>ok</p>



<a name="128311148"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128311148" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128311148">(Jun 19 2018 at 15:37)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://paper.dropbox.com/doc/Issue-51195--AFjUtJ8u3V7OKKrxMgCuh3a0AQ-t4zFz77cMeB6Se08GuC2r" target="_blank" title="https://paper.dropbox.com/doc/Issue-51195--AFjUtJ8u3V7OKKrxMgCuh3a0AQ-t4zFz77cMeB6Se08GuC2r">https://paper.dropbox.com/doc/Issue-51195--AFjUtJ8u3V7OKKrxMgCuh3a0AQ-t4zFz77cMeB6Se08GuC2r</a></p>



<a name="128311191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128311191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128311191">(Jun 19 2018 at 15:38)</a>:</h4>
<p>adding more examples</p>



<a name="128311897"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128311897" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128311897">(Jun 19 2018 at 15:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> great :) it'd be nice to have the locals etc too, not just their scopes</p>



<a name="128311951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128311951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128311951">(Jun 19 2018 at 15:54)</a>:</h4>
<p>good case where a debugger would be helpful</p>



<a name="128311952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128311952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128311952">(Jun 19 2018 at 15:54)</a>:</h4>
<p>sigh</p>



<a name="128312256"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312256" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312256">(Jun 19 2018 at 16:01)</a>:</h4>
<p>well ... interesting</p>



<a name="128312258"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312258" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312258">(Jun 19 2018 at 16:01)</a>:</h4>
<div class="codehilite"><pre><span></span>RUST_LOG=rustc_mir::borrow_check::nll::explain_borrow RUST_BACKTRACE=1 rustc +stage1 -Zborrowck=mir -Ztwo-phase-borrows -Zdump-mir=nll src/test/ui/error-codes/E0597.rs
error[E0597]: `y` does not live long enough
  --&gt; src/test/ui/error-codes/E0597.rs:18:16
   |
18 |     x.x = Some(&amp;y);
   |                ^^ borrowed value does not live long enough
19 |     //~^ `y` does not live long enough [E0597]
20 | }
   | -
   | |
   | borrowed value only lives until here
   | borrow later used here, when `x` is dropped

error: aborting due to previous error

For more information about this error, try `rustc --explain E0597`.
</pre></div>



<a name="128312265"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312265" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312265">(Jun 19 2018 at 16:01)</a>:</h4>
<p>this is the case that is supposed to be printing the note</p>



<a name="128312317"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312317" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312317">(Jun 19 2018 at 16:02)</a>:</h4>
<p>need to add more debug calls</p>



<a name="128312321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312321">(Jun 19 2018 at 16:02)</a>:</h4>
<p>but it's not going in that area of the code</p>



<a name="128312521"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312521" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312521">(Jun 19 2018 at 16:07)</a>:</h4>
<p>OHH man!</p>



<a name="128312523"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128312523" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128312523">(Jun 19 2018 at 16:07)</a>:</h4>
<p>hehe I've made the silliest mistake ever</p>



<a name="128314229"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128314229" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128314229">(Jun 19 2018 at 16:48)</a>:</h4>
<p>I had a feeling :)</p>



<a name="128314689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128314689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128314689">(Jun 19 2018 at 16:58)</a>:</h4>
<p>:)</p>



<a name="128314692"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128314692" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128314692">(Jun 19 2018 at 16:58)</a>:</h4>
<p>pushing again</p>



<a name="128314716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128314716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128314716">(Jun 19 2018 at 16:59)</a>:</h4>
<p><a href="https://github.com/spastorino/rust/commit/a1a30ec8c79771693b338f9ece9415f91500bd49" target="_blank" title="https://github.com/spastorino/rust/commit/a1a30ec8c79771693b338f9ece9415f91500bd49">https://github.com/spastorino/rust/commit/a1a30ec8c79771693b338f9ece9415f91500bd49</a></p>



<a name="128314722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128314722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128314722">(Jun 19 2018 at 16:59)</a>:</h4>
<p>need to change where are we suggesting this thing to see if it's 100% right or not</p>



<a name="128315299"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315299" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315299">(Jun 19 2018 at 17:11)</a>:</h4>
<p>still got <a href="https://github.com/spastorino/rust/commit/a1a30ec8c79771693b338f9ece9415f91500bd49#diff-ae6caad4b0eb05799bbbd3eeb98f64d7R13" target="_blank" title="https://github.com/spastorino/rust/commit/a1a30ec8c79771693b338f9ece9415f91500bd49#diff-ae6caad4b0eb05799bbbd3eeb98f64d7R13">that weird ICE thing going on</a></p>



<a name="128315700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315700">(Jun 19 2018 at 17:21)</a>:</h4>
<p>ahh ya</p>



<a name="128315709"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315709" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315709">(Jun 19 2018 at 17:21)</a>:</h4>
<p>let me fix that</p>



<a name="128315810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315810">(Jun 19 2018 at 17:23)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> done <a href="https://github.com/spastorino/rust/commit/e669d462303536e33bd8740ead5306bfd37d04d5" target="_blank" title="https://github.com/spastorino/rust/commit/e669d462303536e33bd8740ead5306bfd37d04d5">https://github.com/spastorino/rust/commit/e669d462303536e33bd8740ead5306bfd37d04d5</a></p>



<a name="128315816"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315816" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315816">(Jun 19 2018 at 17:23)</a>:</h4>
<p>nice</p>



<a name="128315821"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315821" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315821">(Jun 19 2018 at 17:23)</a>:</h4>
<p>do the changed tests "feel reasonable"?</p>



<a name="128315875"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315875" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315875">(Jun 19 2018 at 17:24)</a>:</h4>
<p>I'm checking that</p>



<a name="128315979"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315979" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315979">(Jun 19 2018 at 17:27)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> I think it makes sense</p>



<a name="128315986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315986">(Jun 19 2018 at 17:27)</a>:</h4>
<p>I've checked some examples that are correct from my point of view</p>



<a name="128315989"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128315989" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128315989">(Jun 19 2018 at 17:27)</a>:</h4>
<p>will check a bit more</p>



<a name="128316127"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316127" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316127">(Jun 19 2018 at 17:30)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> what happens in <code> let (last_dropped, foo0);</code> ?</p>



<a name="128316131"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316131" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316131">(Jun 19 2018 at 17:30)</a>:</h4>
<p><code>foo0.something = &amp;last_dropped;</code></p>



<a name="128316159"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316159" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316159">(Jun 19 2018 at 17:31)</a>:</h4>
<p>I guess in this case is considered that both things are dropped at the same time</p>



<a name="128316165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316165">(Jun 19 2018 at 17:31)</a>:</h4>
<p>so the definition order thing still applies</p>



<a name="128316219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316219">(Jun 19 2018 at 17:32)</a>:</h4>
<p>anyway something like <code>values in a scope are dropped in the opposite order they are defined</code> may not be 100% correct for this case</p>



<a name="128316504"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316504" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316504">(Jun 19 2018 at 17:38)</a>:</h4>
<p>also unsure what about this <a href="https://github.com/spastorino/rust/blob/e669d462303536e33bd8740ead5306bfd37d04d5/src/test/ui/span/send-is-not-static-std-sync.rs" target="_blank" title="https://github.com/spastorino/rust/blob/e669d462303536e33bd8740ead5306bfd37d04d5/src/test/ui/span/send-is-not-static-std-sync.rs">https://github.com/spastorino/rust/blob/e669d462303536e33bd8740ead5306bfd37d04d5/src/test/ui/span/send-is-not-static-std-sync.rs</a></p>



<a name="128316508"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316508" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316508">(Jun 19 2018 at 17:38)</a>:</h4>
<p>other than that, seems correct</p>



<a name="128316510"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316510" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316510">(Jun 19 2018 at 17:38)</a>:</h4>
<p>opening a PR</p>



<a name="128316786"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128316786" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128316786">(Jun 19 2018 at 17:44)</a>:</h4>
<blockquote>
<p>I guess in this case is considered that both things are dropped at the same time</p>
</blockquote>
<p>well, there <em>is</em> an order -- we used to sort of hide it (in the AST days), but in MIR we do not. <span class="user-mention" data-user-id="116266">@Santiago Pastorino</span> and I felt like this was OK, since we can't really <em>change</em> the ordering anyway.</p>



<a name="128317417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317417">(Jun 19 2018 at 17:56)</a>:</h4>
<p>ok</p>



<a name="128317421"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317421" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317421">(Jun 19 2018 at 17:56)</a>:</h4>
<p>yeah, I know there's an order in MIR</p>



<a name="128317432"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317432" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317432">(Jun 19 2018 at 17:56)</a>:</h4>
<p>what I meant is that from a programmer perspective, the message may be confusing</p>



<a name="128317442"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317442" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317442">(Jun 19 2018 at 17:57)</a>:</h4>
<p>unless programmers think about MIR, which I doubt most will do</p>



<a name="128317445"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317445" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317445">(Jun 19 2018 at 17:57)</a>:</h4>
<p>but anyway ...</p>



<a name="128317446"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317446" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317446">(Jun 19 2018 at 17:57)</a>:</h4>
<p>opening a PR</p>



<a name="128317448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128317448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128317448">(Jun 19 2018 at 17:57)</a>:</h4>
<p>running tidy, recompiling, etc</p>



<a name="128318264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318264">(Jun 19 2018 at 18:14)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> <a href="https://github.com/rust-lang/rust/pull/51638" target="_blank" title="https://github.com/rust-lang/rust/pull/51638">https://github.com/rust-lang/rust/pull/51638</a></p>



<a name="128318280"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318280" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318280">(Jun 19 2018 at 18:15)</a>:</h4>
<blockquote>
<p>what I meant is that from a programmer perspective, the message may be confusing</p>
</blockquote>
<p>yeah we may want to rephrase to target this case (e.g., order within a tuple is significant)</p>



<a name="128318560"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318560" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318560">(Jun 19 2018 at 18:20)</a>:</h4>
<p>for some reason I've missed the comments like <a href="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#r29417759" target="_blank" title="https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#r29417759">https://github.com/spastorino/rust/commit/37a565546509b601f356e2d2136bab431c46beff#r29417759</a></p>



<a name="128318562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318562">(Jun 19 2018 at 18:20)</a>:</h4>
<p>I can fix that</p>



<a name="128318567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318567">(Jun 19 2018 at 18:20)</a>:</h4>
<p>how do you want to document that?</p>



<a name="128318577"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318577" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318577">(Jun 19 2018 at 18:21)</a>:</h4>
<p>there are no docs about the parameters of <code>explain_why_borrow_containts_point</code></p>



<a name="128318590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318590">(Jun 19 2018 at 18:21)</a>:</h4>
<p>as fn documentation I meant</p>



<a name="128318595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128318595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128318595">(Jun 19 2018 at 18:21)</a>:</h4>
<p>unsure if you want to add that as the fn documentation</p>



<a name="128319090"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128319090" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128319090">(Jun 19 2018 at 18:30)</a>:</h4>
<p>yeah, I would just add fn documentation</p>



<a name="128319093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128319093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128319093">(Jun 19 2018 at 18:31)</a>:</h4>
<p>ideally explaining all the parameters =)</p>



<a name="128319103"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128319103" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128319103">(Jun 19 2018 at 18:31)</a>:</h4>
<p>but at minimum explaining that one...</p>



<a name="128320578"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128320578" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128320578">(Jun 19 2018 at 18:44)</a>:</h4>
<div class="codehilite"><pre><span></span>    /// Receives the `borrow` and it&#39;s `context`, `kind_place` pair where it&#39;s first element says
    /// if it&#39;s a write or not and the second holds the place that&#39;s being dropped and a `mut err`
    /// where error annotations are going to be added.
</pre></div>



<a name="128320615"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128320615" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128320615">(Jun 19 2018 at 18:44)</a>:</h4>
<p><span class="user-mention" data-user-id="116009">@nikomatsakis</span> fix my shitty english :P</p>



<a name="128320779"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128320779" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128320779">(Jun 19 2018 at 18:45)</a>:</h4>
<p>I think borrow and context are kind of self explanatory given the function name</p>



<a name="128320854"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128320854" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128320854">(Jun 19 2018 at 18:45)</a>:</h4>
<p>wouldn't explain the data structures there</p>



<a name="128320920"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128320920" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128320920">(Jun 19 2018 at 18:45)</a>:</h4>
<p>better to navigate to BorrowData and Context definitions, I guess</p>



<a name="128321126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128321126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128321126">(Jun 19 2018 at 18:46)</a>:</h4>
<p>seems ok. I'd usually put these tthings into more of a list format for easier reading:</p>



<a name="128321366"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128321366" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128321366">(Jun 19 2018 at 18:47)</a>:</h4>
<div class="codehilite"><pre><span></span># Parameters

- `borrow`: borrow..
-  `context`: where the borrow occurs
- `kind_place`: if Some, this describes the statement that triggered the error.
  - first half is the kind of write, if any, being performed
  - second half is the place being accessed
- ...
</pre></div>



<a name="128322365"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322365" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322365">(Jun 19 2018 at 19:08)</a>:</h4>
<p>ok</p>



<a name="128322367"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322367" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322367">(Jun 19 2018 at 19:08)</a>:</h4>
<p>just in case ...</p>



<a name="128322370"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322370" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322370">(Jun 19 2018 at 19:08)</a>:</h4>
<div class="codehilite"><pre><span></span>diff --git a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
index b96c5f5fcc..4f37b338e9 100644
--- a/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
+++ b/src/librustc_mir/borrow_check/nll/explain_borrow/mod.rs
@@ -22,6 +22,15 @@ impl&lt;&#39;cx, &#39;gcx, &#39;tcx&gt; MirBorrowckCtxt&lt;&#39;cx, &#39;gcx, &#39;tcx&gt; {
     /// point from `context`. This is key for the &quot;3-point errors&quot;
     /// [described in the NLL RFC][d].
     ///
+    /// # Parameters
+    ///
+    /// - `borrow`: the borrow in question
+    /// - `context`: where the borrow occurs
+    /// - `kind_place`: if Some, this describes the statement that triggered the error.
+    ///   - first half is the kind of write, if any, being performed
+    ///   - second half is the place being accessed
+    /// - `err`: where the error annotations are going to be added
+    ///
     /// [d]: https://rust-lang.github.io/rfcs/2094-nll.html#leveraging-intuition-framing-errors-in-terms-of-points
     pub(in borrow_check) fn explain_why_borrow_contains_point(
         &amp;mut self,
</pre></div>



<a name="128322397"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322397" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322397">(Jun 19 2018 at 19:09)</a>:</h4>
<p>looks perfect</p>



<a name="128322453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322453">(Jun 19 2018 at 19:10)</a>:</h4>
<p>ok, PR is ready then :)</p>



<a name="128322456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Santiago Pastorino <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322456">(Jun 19 2018 at 19:10)</a>:</h4>
<p>let's wait for the CI :)</p>



<a name="128322482"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order/near/128322482" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/122657-t-compiler/wg-nll/topic/issue-51195-warning-about-variable-declaration-order.html#128322482">(Jun 19 2018 at 19:11)</a>:</h4>
<p>nice!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>